break;
case WAYPT__OFS + 1:
- wpt->description = xstrdup(cin);
+ wpt->description = (cin);
break;
case WAYPT__OFS + 2:
case WPT_cA_OFS + 1:
case WPT_c1_OFS + 1:
-#if NEW_STRINGS
wpt->shortname = cin;
-#else
- if (wpt->shortname) {
- xfree(wpt->shortname);
- }
- wpt->shortname = xstrdup(cin);
-#endif
break;
case WPT_cA_OFS + 4:
cin--;
}
if (cin >= buff) {
- wpt->shortname = xstrndup(buff, cin - buff + 1);
+ char*s = xstrndup(buff, cin - buff + 1);
+ wpt->shortname = s;
+ xfree(s);
}
if (gardown) {
s = strrchr(cdata, ',');
if (s) {
*s = '\0';
- head->rte_name = xstrdup(cdata);
+ head->rte_name = cdata;
}
}
}
head = route_head_alloc();
cdata += 3; /*skip route number */
if (*cdata) {
- head->rte_name = xstrdup(cdata);
+ head->rte_name = cdata;
}
route_add_head(head);
break;
strftime(routename,sizeof(routename),"Tracklog %c",gmtime(&tx));
route = route_head_alloc();
- route->rte_name=xstrdup(routename);
+ route->rte_name = routename;
route_add_head(route);
line=0;
#define fread_single(a) gbfgetflt(a)
#define fread_double(a) gbfgetdbl(a)
-static char*
+QString
fread_string(gbfile* fd)
{
char* val;
len--;
}
val[len] = 0;
- return val;
+ QString v(val);
+ xfree(val);
+ return v;
}
static void
fread_string_discard(gbfile* fd)
{
- char* temp = fread_string(fd);
-
- if (temp != NULL) {
- xfree(temp);
- }
+ fread_string(fd);
}
-static char*
+QString
fread_fixedstring(gbfile* fd, int len)
{
char* val = (char*) xmalloc(len+1);
len--;
}
val[len] = 0;
- return val;
+ QString v(val);
+ xfree(val);
+
+ return v;
}
/* Write functions, according to specification. */
gtm_rd_init(const char* fname)
{
int version;
- char* name;
file_in = gbfopen_le(fname, "rb", MYNAME);
version = fread_integer(file_in);
- name = fread_fixedstring(file_in, 10);
+ QString name = fread_fixedstring(file_in, 10);
if (version == -29921) {
fatal(MYNAME ": Uncompress the file first\n");
}
- if (strcmp(name, "TrackMaker") != 0) {
+ if (name != "TrackMaker") {
fatal(MYNAME ": Invalid file format\n");
}
if (version != 211) {
fatal(MYNAME ": Invalid format version\n");
}
- xfree(name);
/* Header */
fread_discard(file_in, 15);
route_head* rte_head = NULL;
waypoint* wpt;
int real_tr_count = 0;
- char* route_name;
unsigned int icon;
int i;
convert_datum(&wpt->latitude, &wpt->longitude);
wpt->shortname = fread_fixedstring(file_in, 10);
wpt->description = fread_string(file_in);
- route_name = fread_string(file_in);
+ QString route_name = fread_string(file_in);
icon = fread_integer(file_in);
if (icon < sizeof(icon_descr)/sizeof(char*)) {
wpt->icon_descr = icon_descr[icon];
rte_head = route_head_alloc();
rte_head->rte_name = route_name;
route_add_head(rte_head);
- } else {
- xfree(route_name);
}
route_add_wpt(rte_head, wpt);
}
static
void ht_ident(xg_string args, const QXmlStreamAttributes* unused)
{
- wpt_tmp->shortname = xstrdup(args);
+ wpt_tmp->shortname = args;
}
static
static
void ht_lat(xg_string args, const QXmlStreamAttributes* unused)
{
-#if NEW_STRINGS
wpt_tmp->latitude = args.toDouble();
-#else
- wpt_tmp->latitude = atof(args);
-#endif
}
static
void ht_long(xg_string args, const QXmlStreamAttributes* unused)
{
-#if NEW_STRINGS
wpt_tmp->longitude = args.toDouble();
-#else
- wpt_tmp->longitude = atof(args);
-#endif
}
static
void ht_alt(xg_string args, const QXmlStreamAttributes* unused)
{
-#if NEW_STRINGS
wpt_tmp->altitude = args.toDouble();
-#else
- wpt_tmp->altitude = atof(args);
-#endif
}
static
static
void ht_trk_ident(xg_string args, const QXmlStreamAttributes* unused)
{
- trk_head->rte_name = xstrdup(args);
+ trk_head->rte_name = args;
}
static
static
void ht_trk_lat(xg_string args, const QXmlStreamAttributes* unused)
{
-#if NEW_STRINGS
wpt_tmp->latitude = args.toDouble();
-#else
- wpt_tmp->latitude = atof(args);
-#endif
}
static
void ht_trk_long(xg_string args, const QXmlStreamAttributes* unused)
{
-#if NEW_STRINGS
wpt_tmp->longitude = args.toDouble();
-#else
- wpt_tmp->longitude = atof(args);
-#endif
}
static
void ht_trk_alt(xg_string args, const QXmlStreamAttributes* unused)
{
-#if NEW_STRINGS
wpt_tmp->altitude = args.toDouble();
-#else
- wpt_tmp->altitude = atof(args);
-#endif
}
strncpy(desc,pWptHxTmp->comment,sizeof(pWptHxTmp->comment));
desc[sizeof(pWptHxTmp->comment)]=0;
- wpt_tmp->shortname = xstrdup(name);
- wpt_tmp->description = xstrdup(desc);
+ wpt_tmp->shortname = name;
+ wpt_tmp->description = desc;
wpt_tmp->SetCreationTime(0);
if (pWptHxTmp->date.year) {
#define MYNAME "ikt"
-static char* name, *text;
+static QString name, text;
static route_head* track;
static waypoint* waypt;
if (track) {
track->rte_name = name;
track_add_head(track);
- name = NULL;
} else if (waypt) {
waypt->shortname = name;
waypt->description = text;
waypt_add(waypt);
- name = NULL;
- text = NULL;
- }
- if (name) {
- xfree(name);
- name = NULL;
- }
- if (text) {
- xfree(text);
- text = NULL;
}
+
+ name = QString();
+ text = QString();
track = NULL;
waypt = NULL;
}
static void
iktobj_name(xg_string args, const QXmlStreamAttributes* unused)
{
- name = xstrdup(args);
+ name = args;
}
static void
iktobj_text(xg_string args, const QXmlStreamAttributes* unused)
{
- text = xstrdup(args);
+ text = args;
}
static void
track = NULL;
waypt = NULL;
- name = NULL;
- text = NULL;
+ name = QString();
+ text = QString();
}
static void
ikt_rd_deinit(void)
{
ikt_object_end();
- if (name) {
- xfree(name);
- }
- if (text) {
- xfree(text);
- }
-
xml_deinit();
}